<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="author" content="lzy">
    <title>lzy-</title>
    <style>
        html,body{
            height: 100%;
        }
        body{
            margin: 0;
        }
        .header{
            width: 60px;
            height: 20px;
            border: 2px solid blue;
            margin: 20px auto;
            border-radius: 5px;
            text-align: center;
            background-color: gray;
            cursor: pointer;
            line-height: 20px;
        }
        .main{
            width: 80px;
            height: 120px;
            margin: 20px auto;
            border: 2px solid blue;
            display: none;
        }
        li{
            width: 80px;
            height: 40px;
            margin: 0 auto;
            list-style: none;
            line-height: 40px;
            text-align: center;
            cursor: pointer;
            background-color: transparent;
        }
        li:nth-child(2){
            border-bottom: 2px solid blue;
        }
    </style>
</head>
<body>
    <div class="header" onclick="show()">输入法</div>
    <div class="main">
        <li>手写</li>
        <li>拼音</li>
        <li>关闭</li>
    </div>   
</body>
</html>
<script>
    var main = document.querySelector('.main');
    var lis = document.querySelectorAll('li');
    function show(){
        main.style.display='block';
        for(var i=0;i<lis.length;i++){     
            lis[i].onmouseover=function(){
                 for(var i=0;i<lis.length;i++){
                    lis[i].style.backgroundColor='transparent';
                    }
                this.style.backgroundColor='blue';
            }
            lis[i].onclick=function(){
                main.style.display='none';
            }
        }
    }
</script>